package com.leoman.dao;

import com.leoman.entity.Paper;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * PaperDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:44.
 */
public interface PaperDao extends JpaRepository<Paper, Integer>, JpaSpecificationExecutor<Paper> {

    @Query("select a from Paper a where a.user.id = ?1 and a.isDraft = 1")
    Paper iFindDraftByUserId(Integer userId);

    @Query("select a from Paper a where a.isDraft = 0 and a.isTop = 1")
    Paper iFindOneWithTop();

    @Query("select a from Paper a where a.isAdmin = 1")
    Paper iFindOneWithAdmin();
}